{extend name="base" /}
{block name="body"}
<div class="layui-card">
	<div class="layui-card-body">
        <div class="layui-btn-group">
		    <a onclick="add()" class="layui-btn"><i class="fa fa-plus-circle"></i> 添加元数据类型</a>
        </div>
		<table class="layui-table layui-form">
			<thead>
			<tr>
				<th>类型名称</th>
				<th>说明</th>
				<th>元数据样例</th>
				<th>操作</th>
			</tr>
			</thead>
			<tbody>
			{foreach name="list" item="v" empty="$empty"}
			<tr>
				<td>{$v.name}</td>
				<td>{$v.note}</td>
				<td>
					<a href="{:url('admin/metadatatype/downloadOrUpload', ['id' => $v.id])}" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i>
						{if condition="empty($v.template_url)"}{else/}样例下载{/if}</td>
					</a>
				<td>
					{if condition="$v.is_system eq 1" }
						<a onclick="edit({$v.id})" class="layui-btn layui-btn-xs layui-btn-normal"><i class="fa fa-edit"></i> 编辑</a>
						<a href="{:url('admin/metadatatype/del', ['id' => $v.id])}" class="layui-btn layui-btn-xs layui-btn-danger ajax-delete"><i class="fa fa-trash-o"></i> 删除</a>
					{/if}
				</td>
			</tr>
			{/foreach}
			</tbody>
		</table>
	</div>
</div>
{/block}
{block name="js"}
<script>
	//iframe 层
	function add() {
		layer.open({
			type: 2,
			title: '添加类型',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/metadatatype/add',
		});
	}

	function edit(data) {
		layer.open({
			type: 2,
			title: '修改类型',
			shadeClose: true,
			shade: false,
			area: ['860px', '600px'],
			content: '/admin/metadatatype/edit?id=' + data,
		});
	}
</script>
{/block}